"use strict";BX.namespace("BX.Rest.Marketplace.Detail");BX.Rest.Marketplace.Detail={init:function(t){t=typeof t==="object"?t:{};this.ajaxPath=t.ajaxPath||null;this.siteId=t.siteId||null;this.appName=t.appName||"";this.appCode=t.appCode||"";this.importUrl=t.importUrl||"";this.openImport=t.openImport||false;this.description=document.querySelector('[data-role="mp-detail-main-description"]');this.descriptionWrapper=document.querySelector('[data-role="mp-detail-main-description-wrapper"]');if(this.openImport===true&&t.importUrl!==""){BX.SidePanel.Instance.open(t.importUrl)}if(BX.type.isDomNode(BX("detail_cont"))){var e=BX("detail_cont").getElementsByClassName("js-employee-install-button");if(BX.type.isDomNode(e[0])){BX.bind(e[0],"click",BX.proxy(function(){this.confirmInstallRequest(BX.proxy_context)},this))}}this.initTabs()},initTabs:function(){this.slicker=document.querySelector('[data-role="mp-detail-content-menu-border"]');this.menuItems=document.querySelectorAll(".mp-detail-content-menu-item");this.menuItemActive;this.contentItems=document.querySelectorAll(".mp-detail-content-wrapper-item");this.contentActiveItem;for(var t=0;t<this.menuItems.length;t++){var e=this.menuItems[t];BX.bind(e,"click",BX.proxy(function(){this.setActiveItem(BX.proxy_context)},this))}this.setSlickerParam()},setSlickerParam:function(){this.menuItemActive=document.querySelector(".mp-detail-content-menu-item-active");this.slicker.style.left=this.menuItemActive.offsetLeft+"px";this.slicker.style.width=this.menuItemActive.offsetWidth+"px"},setActiveItem:function(t){if(BX.hasClass(t,"mp-detail-content-menu-item-active"))return;for(var e=0;e<this.menuItems.length;e++){BX.removeClass(this.menuItems[e],"mp-detail-content-menu-item-active")}BX.addClass(t,"mp-detail-content-menu-item-active");this.setSlickerParam();this.setActiveContainer(t.getAttribute("for"))},setActiveContainer:function(t){this.contentActiveItem=document.getElementById(t);for(var e=0;e<this.contentItems.length;e++){BX.removeClass(this.contentItems[e],"mp-detail-content-wrapper-item-active")}BX.addClass(this.contentActiveItem,"mp-detail-content-wrapper-item-active")},slideDescription:function(){if(!this.description.style.maxHeight){this.description.style.maxHeight=this.descriptionWrapper.offsetHeight+"px"}else{this.description.style.maxHeight=""}},confirmInstallRequest:function(t){var e=BX.PopupWindowManager.create("mp_install_confirm_popup",null,{content:'<div class="mp_install_confirm"><div class="mp_install_confirm_text">'+BX.message("REST_MP_INSTALL_REQUEST_CONFIRM")+"</div></div>",closeByEsc:true,closeIcon:{top:"1px",right:"10px"},buttons:[new BX.PopupWindowButton({text:BX.message("REST_MP_APP_INSTALL_REQUEST"),className:"popup-window-button-accept",events:{click:BX.delegate(function(){e.close();this.sendInstallRequest(t)},this)}}),new BX.PopupWindowButtonLink({text:BX.message("JS_CORE_WINDOW_CANCEL"),className:"popup-window-button-link-cancel",events:{click:function(){this.popupWindow.close()}}})]});e.show()},sendInstallRequest:function(t){BX.PopupWindowManager.create("mp-detail-block",t,{content:BX.message("MARKETPLACE_APP_INSTALL_REQUEST"),angle:{offset:35},offsetTop:8,autoHide:true}).show();BX.ajax({method:"POST",dataType:"json",url:this.ajaxPath,data:{sessid:BX.bitrix_sessid(),site_id:this.siteId,action:"sendInstallRequest",appName:this.appName,appCode:this.appCode},onsuccess:function(){},onfailure:function(){}})}};BX.namespace("BX.Rest.Marketplace.DetailImageScroller");BX.Rest.Marketplace.DetailImageScroller=function(t){this.param=t;this.layout={container:t.target,wrapper:t.target.querySelector(".mp-detail-image-scroller-wrapper"),earLeft:null,earRight:null};this.earTimer=null};BX.Rest.Marketplace.DetailImageScroller.prototype={init:function(){if(!BX.type.isDomNode(this.layout.container))return;this.layout.container.appendChild(this.getEarLeft());this.layout.container.appendChild(this.getEarRight());this.bindEvents();this.adjustEars()},bindEvents:function(){BX.bind(this.layout.wrapper,"scroll",this.adjustEars.bind(this))},getEarLeft:function(){if(this.layout.earLeft)return this.layout.earLeft;return this.layout.earLeft=BX.create("div",{props:{className:"mp-detail-image-scroller-ear mp-detail-image-scroller-ear-left"},events:{mouseenter:this.scrollToLeft.bind(this),mouseleave:this.stopAutoScroll.bind(this)}})},getEarRight:function(){if(this.layout.earRight)return this.scroller.earRight;return this.layout.earRight=BX.create("div",{props:{className:"mp-detail-image-scroller-ear mp-detail-image-scroller-ear-right"},events:{mouseenter:this.scrollToRight.bind(this),mouseleave:this.stopAutoScroll.bind(this)}})},scrollToRight:function(){this.earTimer=setInterval(function(){this.layout.wrapper.scrollLeft+=10}.bind(this),20)},scrollToLeft:function(){this.earTimer=setInterval(function(){this.layout.wrapper.scrollLeft-=10}.bind(this),20)},stopAutoScroll:function(){clearInterval(this.earTimer)},adjustEars:function(){var t=this.layout.wrapper;var e=t.scrollLeft;var i=e>0;var s=t.scrollWidth>Math.round(e+t.offsetWidth);this.layout.container.classList[i?"add":"remove"]("mp-detail-image-scroller-ear-left-shown");this.layout.container.classList[s?"add":"remove"]("mp-detail-image-scroller-ear-right-shown")}};
//# sourceMappingURL=script.map.js